-
Notifications
You must be signed in to change notification settings - Fork 186
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New function_return_linter()
#1569
Conversation
Wondering whether we should centralize this to |
Good point -- do we have any other linters in the package yet under this umbrella? Smaller point -- what about |
Just glancing over the list, I also see we could put this under |
function_return_linter()
expect_lint( | ||
trim_some(" | ||
foo <- function(x) { | ||
return(x <<- x + 1) | ||
} | ||
"), | ||
lint_msg, | ||
linter | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also add this one for the sake of completeness?
library(lintr)
lint(
text = "foo <- function(x) {
return(x + 1 ->> x)
}
",
linters = function_return_linter()
)
#> <text>:2:16: warning: [function_return_linter] Move the assignment outside of the return() clause, or skip assignment altogether.
#> return(x + 1 ->> x)
#> ^~~~~~~~~~~
Created on 2022-09-30 with reprex v2.0.2
Part of #884